const regUsername = /^[a-zA-Z0-9]{8,30}$/ // 用户名效验
const regPassword = /^[a-zA-Z0-9]{6,30}$/ // 密码效验
// console.log(regUsername.test('2343'));

document.querySelector('.btn').addEventListener('click', function (e) {
    e.preventDefault() // 阻止form表单的默认行为
    const form = document.querySelector('.register-form')
    let data = serialize(form, { hash: true, empty: true })
    console.log(data.username);
    if (regUsername.test(data.username) && regPassword.test(data.password)) {
        axios.post('/register', data)
            .then(res => {
                console.log(res.data);
                pxmu.success('注册成功')
                setTimeout(() => {
                    location.href = './login.html'
                }, 1000)

            })
    } else {
        pxmu.fail('效验不通过')
        return

    }

})